import 'package:flutter/material.dart';
import 'package:renqing/components/form_text.dart';
import 'package:renqing/global.dart';

class TextItem extends StatefulWidget {
  TextItem({
    Key key,
    this.title,
    this.text,
    this.hintText,
    this.onChanged,
    this.keyboardType = TextInputType.text,
  }) : super(key: key);
  final String title;
  final String hintText;
  final String text;
  final onChanged;
  final TextInputType keyboardType;

  @override
  State<StatefulWidget> createState() => _TextItemState();
}

class _TextItemState extends State<TextItem> {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
      width: MediaQuery.of(context).size.width,
      height: 50,
      decoration: BoxDecoration(
        color: Global.backgroundColor,
        border: Border(
          bottom: BorderSide(
            color: Global.fontSecondColor.withOpacity(0.2),
            width: 1,
            style: BorderStyle.solid,
          ),
        ),
      ),
      child: Row(
        children: [
          Text(
            "${widget.title}：",
            style: TextStyle(
              fontSize: 16,
              color: Global.fontColor,
            ),
          ),
          Expanded(
            child: FormText(
                maxLine: 1,
                text: widget.text,
                hintText: widget.hintText,
                keyboardType: widget.keyboardType,
                onChanged: widget.onChanged),
          ),
          SizedBox(width: 10)
        ],
      ),
    );
  }
}
